package com.xiaochun.jiankangapp.fragment

import android.os.Bundle
import android.text.TextUtils
import android.view.View
import com.xiaochun.jiankangapp.base.CViewBinding
import com.xiaochun.jiankangapp.databinding.FragmentInputInfoStep3Binding
import com.xiaochun.jiankangapp.extension.onClick

class InputInfoStep3Fragment : InputInfoBaseFragment() {

    @CViewBinding
    lateinit var viewBinding: FragmentInputInfoStep3Binding
    override fun initView(root: View, savedInstanceState: Bundle?) {
        super.initView(root, savedInstanceState)
        viewBinding.height.dataList = arrayListOf<Any?>().apply {
            for (i in 40..100) {
                add(i + 100)
            }
        }
        viewBinding.weight.dataList = arrayListOf<Any?>().apply {
            for (i in 40..100) {
                add(i)
            }
        }
        viewBinding.height.setOnWheelChangeListener { item, position ->
            inputViewModel.height = item as Int
        }
        viewBinding.weight.setOnWheelChangeListener { item, position ->
            inputViewModel.weight = item as Int
        }
        viewBinding.next.onClick {
            if (inputViewModel.weight == 0 || inputViewModel.height == 0) {
                return@onClick
            }
            replaceNext(InputInfoStep4Fragment::class.java)
        }
    }
}